/**
 * PreferenceManager.h
 * @author Nick Kreeger <nick.kreeger@park.edu>
 * @author Mozilla.org
 */

#import <AppKit/AppKit.h>
#import <Carbon/Carbon.h>

class nsProfileDirServiceProvider;
class nsIPref;

extern NSString* const kPrefChangedNotificationName;
extern NSString* const kPrefChangedPrefNameUserInfoKey;

@interface PreferenceManager : NSObject 
{
@private
  nsProfileDirServiceProvider* mProfileProvider;
  nsIPref*                     mPrefs;
  NSUserDefaults*              mDefaults;
  
  NSMutableDictionary* mPrefChangeObservers; // dict of NSMutableArray of PrefChangeObserverOwner, keyed by pref name.
  
  long                 mLastRunPrefsVersion;
  NSString*            mProfilePath;
  
  // proxies notification stuff
  CFRunLoopSourceRef   mRunLoopSource;
}

+(PreferenceManager*)sharedInstance;
+(PreferenceManager*)sharedInstanceDontCreate;

-(BOOL)initMozillaPrefs;
-(void)syncMozillaPrefs;
-(void)savePrefsFile;

-(NSString*)getStringPref: (const char*)prefName withSuccess:(BOOL*)outSuccess;
-(NSColor*)getColorPref: (const char*)prefName withSuccess:(BOOL*)outSuccess;
-(BOOL)getBooleanPref: (const char*)prefName withSuccess:(BOOL*)outSuccess;
-(int)getIntPref: (const char*)prefName withSuccess:(BOOL*)outSuccess;

-(void)setPref:(const char*)prefName toString:(NSString*)value;
-(void)setPref:(const char*)prefName toInt:(int)value;
-(void)setPref:(const char*)prefName toBoolean:(BOOL)value;

- (NSString*)profilePath;

// turn notifications on and off when the given pref changes. 
// if not nil, inObject is used at the 'object' of the resulting notification.
-(void)addObserver:(id)inObject forPref:(const char*)inPrefName;
-(void)removeObserver:(id)inObject;    // remove from all prefs that it observes
-(void)removeObserver:(id)inObject forPref:(const char*)inPrefName;

@end
